Skip to content

Consolidate useInterval and remove Interval class#350

Merged
huntabyte merged 2 commits intomainfrom
consolidate-interval
Oct 13, 2025
Merged

Consolidate useInterval and remove Interval class#350
huntabyte merged 2 commits intomainfrom
consolidate-interval

Conversation

@TGlide
Copy link
Member

@TGlide TGlide commented Oct 13, 2025

Summary

  • Consolidates functionality from Interval class into useInterval function
  • Removes deprecated Interval class and all related files
  • Fixes a bug where useInterval would not update setInterval's delay prop reactively

Migration

Users of useInterval should change how they use it:

// Before
const interval = useInterval(() => console.log('hi'), 1000);

// After
const interval = useInterval(1000, {
  callback: () => console.log('hi')
});

Users of Interval can migrate to useInterval with the callback option:

// Before
const interval = new Interval(1000, {
  callback: (count) => console.log(count)
});

// After
const interval = useInterval(1000, {
  callback: (count) => console.log(count)
});

All properties and methods (counter, isActive, pause(), resume(), reset()) are available on the return value.

@changeset-bot
Copy link

changeset-bot bot commented Oct 13, 2025

🦋 Changeset detected

Latest commit: 90371a0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
runed Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Oct 13, 2025

built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

Name Status Preview Last Commit
runed ❌ Failed (View Log) 90371a0

@github-actions github-actions bot requested a deployment to Preview October 13, 2025 12:20 Abandoned
@TGlide TGlide self-assigned this Oct 13, 2025
@github-actions github-actions bot requested a deployment to Preview October 13, 2025 12:28 Abandoned
Copy link
Member

@huntabyte huntabyte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@huntabyte huntabyte merged commit 03fd527 into main Oct 13, 2025
4 checks passed
@huntabyte huntabyte deleted the consolidate-interval branch October 13, 2025 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants